<template>
    <!-- 查快递 -->
    <view class="checkExpress">
        <view class="search-box">
            <view class="search-input">
                <image class="home_icon_shous_nor" src="../../static/images/home_icon_shous_nor.png" mode=""></image>
                <input v-model="keyword" type="text" value=""placeholder="请输入查询打单号" class="placeholder-class" />
            </view>
            <image @click="scanCodeFun" class="home_icon_saoma_nor" src="../../static/images/home_icon_saoma_nor.png" mode=""></image>
        </view>
        <view class="express-type">
            <view :class="{active: type == 1}" @click="typeFun(1)">
                我寄出的
            </view>
            <view :class="{active: type == 2}" @click="typeFun(2)">
                我收到的
            </view>
        </view>
        
        
        <view style="margin: 20rpx;">
            <view class="detail" v-for="(item, i) in list" :key="i" @click="rowClick(item)">
                <view class="number">
                    <view>运单号：SZL100057281 <text style="color: #f04545"> (￥18)</text></view>
                    <view class="state">待收件</view>
                </view>
                <view class="time">
                    下单时间：2021-03-22  16：21
                </view>
                <view class="f-t">
                    <view class="from">
                        <view class="city">赣州市</view>
                        <view>徐徐徐</view>
                    </view>
                    <image class="home_icon_fangx_nor" src="../../static/images/home_icon_fangx_nor.png" mode=""></image>
                    <view class="from">
                        <view class="city">赣州市</view>
                        <view>徐徐徐</view>
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
import optionList from '@/components/gzz-option-list/option-list';
export default {
    components: {
        optionList
    },
    data() {
        return {
            type: 1,
            keyword: '',
            // waybillNum=”运单单号”   
            list: [ {waybillNum: 'hy086a'}, {waybillNum: 'hy035a'}, {waybillNum: 'hy872643812'} ],
            itemHeight: 330,
            options: [
                {
                    color: '#ffffff',
                    bgColor: '#FF4058',
                    text: '删除',
                    width: 160,
                }
            ],
            threshold: 50,
            timer: null
        }
    },
    watch:{
        keyword(){
            clearTimeout(this.timer);
            this.timer = setTimeout( () => {
                console.log(111)
            },500)
        }
    },
    onLoad() {
        
    },
    methods: {
        scanCodeFun() {
            let that = this
            uni.scanCode({
                onlyFromCamera: true,
                success: function(res) {
                    that.app.toast(res.result)
                }
            })
        },
        typeFun(t) {
            this.type = t
        },
        listDelete(item,index){
            this.list.splice(index,1)
        },
        rowClick(item){
            uni.navigateTo({
                url: `/pages/checkExpress/detail?waybillNum=${item.waybillNum}`
            })
        },
    }
}
</script>

<style lang="less" scoped>
.checkExpress{
    
}

.search-box{
    padding: 14rpx 26rpx;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    
    .search-input{
        flex: 1;
        height: 66rpx;
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: #f6f6f6;
        border-radius: 33rpx;
        padding: 0 20rpx;
        margin-right: 20rpx;
        
        .home_icon_shous_nor{
            width: 31rpx;
            height: 31rpx;
            margin-right: 10rpx;
        }
        input{
            flex: 1;
            color: #333333;
        }
        
        
    }
    
    .home_icon_saoma_nor{
        width: 42rpx;
        height: 39rpx;
    }
}

.express-type{
    display: flex;
    padding: 24rpx 0 30rpx 0;
    background: #fff;
    view{
        flex: 1;
        text-align: center;
        position: relative;
        
        font-size: 34rpx;
        
        &.active{
            color: #f04545;
            &::after{
                display: block;
                content: '';
                position: absolute;
                bottom: -30rpx;
                left: 50%;
                transform: translateX(-50%);
                width: 50rpx;
                height: 6rpx;
                background: #f04545;
            }
        }
    }
    
}

.detail{
    background: #fff;
    border-radius: 20rpx;
    padding: 34rpx 20rpx;
    font-size: 28rpx;
    margin-bottom: 26rpx;
    
    .number{
        display: flex;
        align-items: center;
        justify-content: space-between;
        color: #333333;
        padding: 0 10rpx 34rpx 10rpx;
        border-bottom: 1rpx solid #dfdfdf;
        
        .state{
            color: #f04545;
        }
        
    }
    
    .time{
        margin-top: 20rpx;
        color: #999999;
        font-size: 26rpx;
        padding-left: 16rpx;
    }
    
    .f-t{
        margin-top: 40rpx;
        display: flex;
        align-items: center;
        .from{
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            color: #999999;
            
            .city{
                font-size: 36rpx;
                color: #333;
                margin-bottom: 8rpx;
            }
        }
        
        .home_icon_fangx_nor{
            width: 120rpx;
            height: 7rpx;
        }
    }
}

.placeholder-class{
    color: #cccccc;
    font-size: 26rpx;
}
</style>
